<?php include('top.php'); ?>

<div class="reg_box">
    <h3>在线注册</h3>
    <form id="registrationForm">
        <ul>
            <li>证件号码：<input type="text" id="number" class="index_input" name="number">
            <span class="error">请务必填写考生本人的真实证件号码</span></li>
            <li>登入密码：<input type="password" id="password" class="index_input" name="password">
            <span class="error">请务必填写易记并安全的密码</span></li>
            <li>真实姓名：<input type="text" id="name" class="index_input" name="name">
            <span class="error">请务必填写考生本人的真实姓名注册，并与证件一致。</span></li>
            <li>手机号码：<input type="text" id="telephone" class="index_input" name="telephone">
            <span class="error">请务必填写考生本人的真实可用的手机号码</span></li>
            <li>电子邮箱：<input type="email" id="mail" class="index_input" name="mail">
            <span class="error">请务必填写考生本人的真实可用的电子邮箱</span></li>
            <li>
                <?php if (empty($web_info_row['reg'])) { echo "已停止注册"; } else { ?>
                <button class="input_submit">注册</button>
                <?php } ?>
            </li>
        </ul>
    </form>
    <div id="registrationResult"></div>
</div>
<script type="text/javascript" src="static/js/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('#registrationForm').on('submit', function(e){
            e.preventDefault();
            var formData = $(this).serialize();

            $.ajax({
                url: 'reg_post.php',
                type: 'POST',
                data: formData,
                success: function(response){
                    $('#registrationResult').empty();
                    $('#registrationResult').html(response);
                },
                error: function(error){
                    console.log(error);
                    $('#registrationResult').html('注册失败，请稍后再试。');
                }
            });
        });
    });
</script>
<?php include('bottom.php'); ?>